package com.ruoyi.hr.service.impl;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.hr.HrConstants;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.domain.Empchange;
import com.ruoyi.hr.domain.JUser;
import com.ruoyi.hr.mapper.JinpengMapper;
import com.ruoyi.hr.service.JinPengService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.print.attribute.standard.PagesPerMinute;
import java.util.List;
import java.util.Map;

@Service
public class JinPengServiceImpl implements JinPengService {

    @Autowired
    private JinpengMapper demoMapper;

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<JUser> findAll(JUser juser, List<Authority> authorities,int isAdmin) {
        return demoMapper.findAll(juser,authorities,isAdmin);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int findCount(JUser juser, List<Authority> authorities) {
        return demoMapper.findCount(juser,authorities);
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> findAllTree(List<Authority> authorityList,int isAdmin) {
        return demoMapper.findAllTree(authorityList,isAdmin);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public JUser findJuserOne(Long eid) {
        return demoMapper.findJuserOne(eid);
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public String checkBadgeUnique(String badge) {
        int count = demoMapper.checkBadgeUnique(badge);
        if (count > 0)
        {
            return HrConstants.badge_NOT_UNIQUE;
        }
        return HrConstants.badge_UNIQUE;
        }



    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<JUser> findJuser(List<String> allEid) {
        return demoMapper.findJuser(allEid);
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int updateExchange(JUser jUser) {
        return demoMapper.updateExchange(jUser);
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int insertChangeOrg(JUser jUser) {
        return demoMapper.insertChangeOrg(jUser);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int inserteEvent(JUser jUser) {
        return demoMapper.inserteEvent(jUser);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public Empchange findEmpchange(Long eid) {
        return demoMapper.findEmpchange(eid);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int updaterecoveryEx(Empchange empchange) {
        return demoMapper.updaterecoveryEx(empchange);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int findEmpCount() {
        return demoMapper.findEmpCount();
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int findYearMonthMCount(String time) {
        return demoMapper.findYearMonthMCount(time);
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int insertexQuit(List<JUser> jUsers, String effectdate) {
        return demoMapper.insertexQuit(jUsers,effectdate);
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public int updateQuit(List<String> allEid) {
        return demoMapper.updateQuit(allEid);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<JUser> findEvEmp(String effectdate) {
        return demoMapper.findEvEmp(effectdate);
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<String> getEmpRow() {
        return demoMapper.getEmpRow();
    }

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public JUser findEmpByBadge(String badge) {
        return demoMapper.findEmpByBadge(badge);
    }
}
